<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:oui="clr-namespace:OpenLS.UI"
    xmlns:ouit="clr-namespace:OpenLS.UI.Themes"                    
    x:Class="OpenLS.UI.GroupResources"
    >
  <ResourceDictionary.MergedDictionaries>
        <ouit:GroupButtonResources/>
        <ouit:ButtonResources/>
    <ResourceDictionary Source="StackPanelResources.xaml"/>
    <ouit:MenuResources/>
  </ResourceDictionary.MergedDictionaries>
    <ControlTemplate TargetType ="{x:Type oui:Group}" x:Key="expandedGroup">
        <Border BorderBrush ="{TemplateBinding BorderBrush}" BorderThickness ="1" CornerRadius="4"  Margin="{TemplateBinding Margin}" Background="{TemplateBinding Background}">
            <Grid >
                <Grid.RowDefinitions>
                    <RowDefinition Height ="*"/>
                    <RowDefinition Height ="16"/>
                </Grid.RowDefinitions>
                <Rectangle Fill="{TemplateBinding Background}" RadiusX="3" RadiusY="3"></Rectangle>
                <Rectangle Fill="{DynamicResource {x:Static oui:OfficeBrushes.GroupContentHoverBackgroundKey}}" Opacity="0" RadiusX="3" RadiusY="3" x:Name="contentRect"></Rectangle>
                <ItemsPresenter HorizontalAlignment ="Left" VerticalAlignment ="Stretch" Margin="{TemplateBinding Padding}"/>
                <Rectangle Grid.Row ="1" Fill="{DynamicResource {x:Static oui:OfficeBrushes.GroupHeaderBackgroundKey}}" x:Name="headerRect"/>
                <Rectangle Grid.Row ="1" Fill="{DynamicResource {x:Static oui:OfficeBrushes.GroupHeaderHoverBackgroundKey}}" Opacity="0" x:Name="headerHoverRect"/>
                <Grid Grid.Row="1" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <ContentControl
                        HorizontalAlignment ="Stretch" Foreground="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}" Background ="#FFC2D9F0"
          Content ="{TemplateBinding Header}" HorizontalContentAlignment="Center" TextBlock.TextAlignment="Center"></ContentControl>
                    <Button Grid.Column ="1" Command ="{TemplateBinding Command}" Style="{StaticResource groupButton}" 
                  CommandParameter="{TemplateBinding CommandParameter}" Name="s2Button" Visibility="Visible"/>
                </Grid>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
                <EventTrigger RoutedEvent="UIElement.MouseEnter">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="headerHoverRect" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.5" />

                            <DoubleAnimation Storyboard.TargetName="contentRect" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.5" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
            <EventTrigger RoutedEvent="UIElement.MouseLeave">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="headerHoverRect" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.5" />

                            <DoubleAnimation Storyboard.TargetName="contentRect" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.5" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
            <Trigger Property="Command" Value="{x:Null}">
                <Setter Property="Visibility" Value="Collapsed" TargetName="s2Button"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="toggleGroupStyle" TargetType="{x:Type ToggleButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border x:Name="ClassicBorder"
                  Background="{TemplateBinding Background}" CornerRadius="2" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
            <DockPanel x:Name="ContentPanel" Background="Transparent">
              <Path Data="M0,0 L6,0 L3,2 Z" Fill ="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="2"/>
              <ContentPresenter x:Name="ContentHost" Margin="{TemplateBinding Padding}" DockPanel.Dock="Bottom"/>
            </DockPanel>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GroupContentBackgroundKey}}"/>
    <Setter Property="Padding" Value="4 6 4 6"/>
    <Style.Triggers>
      <Trigger Property="IsChecked" Value="true">
        <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GroupContentPressedBackgroundKey}}"  />
      </Trigger>
     <!-- <Trigger Property="IsMouseOver" Value="true">
                <Trigger.EnterActions>
                    
                </Trigger.EnterActions>
                <Trigger.ExitActions></Trigger.ExitActions>

      </Trigger> -->
    </Style.Triggers>
  </Style>
  
  <ControlTemplate TargetType="{x:Type oui:Group}" x:Key="collapsedGroup">
        <Border BorderBrush ="{TemplateBinding BorderBrush}" BorderThickness ="1" CornerRadius="3" Margin="{TemplateBinding Margin}">
      <Grid>
        <ToggleButton Content="{TemplateBinding Header}" Foreground="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}"  x:Name="toggle" Click="OnToggleClick" VerticalAlignment ="Stretch"
                     Style="{StaticResource toggleGroupStyle}"  BorderBrush="{x:Null}" BorderThickness="0"/>
        <Popup PlacementTarget="{Binding ElementName=toggle}" x:Name="popup" StaysOpen="False" Closed="OnPopupClosed" MaxHeight="96" >
          <Border BorderBrush ="#7eadd3" BorderThickness ="1" CornerRadius="3">
            <Grid Background="#c8e0ff">
              <Grid.RowDefinitions>
                <RowDefinition Height ="*"/>
                <RowDefinition Height ="16"/>
              </Grid.RowDefinitions>
              <Rectangle Fill="{TemplateBinding Background}">
              </Rectangle>
              <ItemsPresenter HorizontalAlignment ="Left" VerticalAlignment ="Center"/>
              <ContentControl
              HorizontalAlignment ="Stretch"
              Foreground="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}" Background ="#c8e0ff"
              Content ="{TemplateBinding Header}" Grid.Row="1" TextBlock.TextAlignment="Center"/>
            </Grid>
          </Border>
        </Popup>
      </Grid>

    </Border>
  </ControlTemplate>
    <Style TargetType="{x:Type oui:Group}" x:Key="{x:Static oui:Styles.GroupStyleKey}">
        <Style.Resources>
            <Style TargetType="{x:Type StackPanel}" BasedOn="{StaticResource ribbonStackPanel}"/>
            <!--<Style TargetType="{x:Type Button}" BasedOn="{StaticResource AutomaticRibbonButton}"/> -->
        </Style.Resources>
        <Setter Property="Template" Value="{StaticResource expandedGroup}"/>
        <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GroupContentBackgroundKey}}"/>
        <Setter Property="Margin" Value="1 0.5 1 0.5"/>
        <Setter Property="Padding"  Value="4 0 4 0" />
        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.GroupBorderBrushKey}}"></Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
       <!-- <EventSetter Event="Loaded" Handler="OnLoaded"></EventSetter> -->
        <Style.Triggers>
           <!-- <Trigger Property ="IsMouseOver" Value="True">
                <Trigger.EnterActions></Trigger.EnterActions>
                <Trigger.ExitActions></Trigger.ExitActions>
                <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GroupContentHoverBackgroundKey}}"/>
            </Trigger> -->
            <Trigger Property ="oui:Group.GroupState" Value="Collapsed">
                <Setter Property="Template" Value="{StaticResource collapsedGroup}"/>
            </Trigger>
        </Style.Triggers>
    </Style>


</ResourceDictionary>